    <!-- jQuery -->
    <script src="/vendor/jquery/jquery.min.js"></script>

    <!-- Tooltips -->
    <script src="/js/popper.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="/vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="/vendor/metisMenu/metisMenu.min.js"></script>

    <!-- DataTables JavaScript -->
    <!--<script src="../vendor/datatables/js/jquery.dataTables.min.js"></script>-->
    <script src="/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="/vendor/datatables-responsive/dataTables.responsive.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="/dist/js/sb-admin-2.js"></script>

    <!-- DexcaliburAPI helper -->
    <script src="/js/wexcalibur.js"></script>


    <script type="text/javascript">
    $(document).ready(function(){
        let url = null;
        if(location.href.indexOf("#")>-1)
            url = location.href.substr(0,location.href.indexOf("#"));
        else
            url = location.href;

        let m = false;

        var element = $('ul.navbar-nav li.nav-item a.nav-link').filter(function() {
            //console.log(this.href,url,this.href == url);
            return this.href == url;
        }).addClass('active').parent();

        if(element != null){
            element.addClass('active');
        }
        
        if(element==null || element.length == 0){
            element = $('ul.navbar-nav li.nav-item a.dropdown-item').filter(function() {
                //console.log(this.href,url,this.href == url);
                return this.href == url;
            }).parent().parent().addClass('active');
        }

        DexcaliburAPI.project.autosaveStatus(
            function(data){
                //let d = JSON.parse(data);
                //console.log(d);
                let menu = $("#autosaveMenu").last();
                let status = $("#saveStatus").last();
                let statusSwitch = $("#autosaveSwitch").last();

                if(data.enable==false){
                    status.removeClass("text-warning");
                    status.addClass("text-danger");
                    status.html("OFF");
                    statusSwitch.removeAttr("checked");
                    menu.css("visibility","visible");
                }else{
                    status.removeClass("text-danger");
                    status.addClass("text-warning");
                    status.html("ON");
                    statusSwitch.attr("checked","");
                    menu.css("visibility","visible");
                }
            },
            (err)=>{
                console.log("[DEBUG] ",err);
            }
        );

        $("#autosaveSwitch").change(function(e){
            let status = $("#saveStatus").last();
            let statusSwitch = $("#autosaveSwitch").last();

            if( status.html() == "ON"){
                DexcaliburAPI.project.autoSave("off",
                    function(){
                        status.removeClass("text-warning");
                        status.addClass("text-danger");
                        status.html("OFF");
                    },
                    function(){
                        alert("Auto-save cannot be turn OFF");
                    }
                );
            }else{
                DexcaliburAPI.project.autoSave("on",
                    function(){
                        status.removeClass("text-danger");
                        status.addClass("text-warning");
                        status.html("ON");
                    },
                    function(){
                        alert("Auto-save cannot be turn ON");
                    }
                );
            }
        });
        /*
        $(".navbar-nav > li:first-child a").map((a,b)=>{
            if(b.href==url){
                b.classList.add("active");
                m=true;
            }
        });

        if(!m){
            $(".navbar-nav > li a:first-child").map((a,b)=>{
                if(b.href==url){
                    b.classList.add("active");
                    m=true;
                }
            }); 
        }*/
        /*
        $(".navbar-nav > li > a").map((a,b)=>{
            if(b.href==url) b.classList.add("active");
        });*/
    });
    </script>

